﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace CommunitySystemModel
{
    public class PeiXunDetailModel
    {
        private int _Sec;
        [DataMember]
        public int Sec
        {
            get { return _Sec; }
            set { _Sec = value; }
        }
        private int _ID;
        [DataMember]
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private int _PeiXunID = 0;
        [DataMember]
        public int PeiXunID
        {
            get { return _PeiXunID; }
            set { _PeiXunID = value; }
        }
        private int _XianZhiPiaoShu;
        [DataMember]
        public int XianZhiPiaoShu
        {
            get { return _XianZhiPiaoShu; }
            set { _XianZhiPiaoShu = value; }
        }
        private int _DingPiaoShu = 0;
        [DataMember]
        public int DingPiaoShu
        {
            get { return _DingPiaoShu; }
            set { _DingPiaoShu = value; }
        }

        private int _OrgID = 0;
        [DataMember]
        public int OrgID
        {
            get { return _OrgID; }
            set { _OrgID = value; }
        }

        private int _YiFaFangPiaoShu = 0;
        [DataMember]
        public int YiFaFangPiaoShu
        {
            get { return _YiFaFangPiaoShu; }
            set { _YiFaFangPiaoShu = value; }
        }

        /// <summary>
        /// 0为未结束，1为已结束
        /// </summary>
        private int _Status;
        [DataMember]
        public int Status
        {
            get { return _Status; }
            set { _Status = value; }
        }

        private string _StatusString;
        [DataMember]
        public string StatusString
        {
            get { return _StatusString; }
            set { _StatusString = value; }
        }

        private string _Name;
        [DataMember]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        private string _ZhuJiangRen;
        [DataMember]
        public string ZhuJiangRen
        {
            get { return _ZhuJiangRen; }
            set { _ZhuJiangRen = value; }
        }

        private string _JiangZuoShiJijan;
        [DataMember]
        public string JiangZuoShiJijan
        {
            get { return _JiangZuoShiJijan; }
            set { _JiangZuoShiJijan = value; }
        }

        private string _JiangZuoDiDian;
        [DataMember]
        public string JiangZuoDiDian
        {
            get { return _JiangZuoDiDian; }
            set { _JiangZuoDiDian = value; }
        }

        private DateTime? _StartTime;
        [DataMember]
        public DateTime? StartTime
        {
            get { return _StartTime; }
            set { _StartTime = value; }
        }

        private DateTime? _EndTime;
        [DataMember]
        public DateTime? EndTime
        {
            get { return _EndTime; }
            set { _EndTime = value; }
        }

        private string _OrgName;
        [DataMember]
        public string OrgName
        {
            get { return _OrgName; }
            set { _OrgName = value; }
        }

        private int _PiaoShu;
        [DataMember]
        public int PiaoShu
        {
            get { return _PiaoShu; }
            set { _PiaoShu = value; }
        }

        private int _YuPiao;
        [DataMember]
        public int YuPiao
        {
            get { return _YuPiao; }
            set { _YuPiao = value; }
        }

        private string _JiangZuoType;
        [DataMember]
        public string JiangZuoType
        {
            get { return _JiangZuoType; }
            set { _JiangZuoType = value; }
        }

        private bool _YiFaFang;
        [DataMember]
        public bool YiFaFang
        {
            get { return _YiFaFang; }
            set { _YiFaFang = value; }
        }

        private string _YiFaFangString = "未发放";
        [DataMember]
        public string YiFaFangString
        {
            get { return _YiFaFangString; }
            set { _YiFaFangString = value; }
        }

        private string _FaFangFangShi;
        [DataMember]
        public string FaFangFangShi
        {
            get { return _FaFangFangShi; }
            set { _FaFangFangShi = value; }
        }
        public static PeiXunDetailModel FillEntity(DataRow dr)
        {
            PeiXunDetailModel right = new PeiXunDetailModel();
            if (dr.Table != null && dr.Table.Columns.Contains("XianZhiPiaoShu")) if (!string.IsNullOrEmpty(dr["XianZhiPiaoShu"].ToString())) right.XianZhiPiaoShu = Convert.ToInt32(dr["XianZhiPiaoShu"]);
            if (dr.Table != null && dr.Table.Columns.Contains("ID")) if (!string.IsNullOrEmpty(dr["ID"].ToString())) right.ID = Convert.ToInt32(dr["ID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("PeiXunID")) if (!string.IsNullOrEmpty(dr["PeiXunID"].ToString())) right.PeiXunID = Convert.ToInt32(dr["PeiXunID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("DingPiaoShu")) if (!string.IsNullOrEmpty(dr["DingPiaoShu"].ToString())) right.DingPiaoShu = Convert.ToInt32(dr["DingPiaoShu"]);
            if (dr.Table != null && dr.Table.Columns.Contains("OrgID")) if (!string.IsNullOrEmpty(dr["OrgID"].ToString())) right.OrgID = Convert.ToInt32(dr["OrgID"]);
            if (dr.Table != null && dr.Table.Columns.Contains("Sec")) if (!string.IsNullOrEmpty(dr["Sec"].ToString())) right.Sec = Convert.ToInt32(dr["Sec"]);
            if (dr.Table != null && dr.Table.Columns.Contains("PiaoShu")) if (!string.IsNullOrEmpty(dr["PiaoShu"].ToString())) right.PiaoShu = Convert.ToInt32(dr["PiaoShu"]);
            if (dr.Table != null && dr.Table.Columns.Contains("YuPiao")) if (!string.IsNullOrEmpty(dr["YuPiao"].ToString())) right.YuPiao = Convert.ToInt32(dr["YuPiao"]);
            if (dr.Table != null && dr.Table.Columns.Contains("YiFaFangPiaoShu")) if (!string.IsNullOrEmpty(dr["YiFaFangPiaoShu"].ToString())) right.YiFaFangPiaoShu = Convert.ToInt32(dr["YiFaFangPiaoShu"]);

            if (dr.Table != null && dr.Table.Columns.Contains("Status")) if (!string.IsNullOrEmpty(dr["Status"].ToString()))
                {
                    right.Status = Convert.ToInt32(dr["Status"]);
                    if (right.Status == 0) right.StatusString = "可订票";
                    if (right.Status == 1) right.StatusString = "已结束";
                }
            if (dr.Table != null && dr.Table.Columns.Contains("JiangZuoType")) if (!string.IsNullOrEmpty(dr["JiangZuoType"].ToString())) right.JiangZuoType = dr["JiangZuoType"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("StartTime")) if (!string.IsNullOrEmpty(dr["StartTime"].ToString())) right.StartTime = Convert.ToDateTime(dr["StartTime"]);
            if (dr.Table != null && dr.Table.Columns.Contains("EndTime")) if (!string.IsNullOrEmpty(dr["EndTime"].ToString())) right.EndTime = Convert.ToDateTime(dr["EndTime"]);

            if (dr.Table != null && dr.Table.Columns.Contains("Name")) if (!string.IsNullOrEmpty(dr["Name"].ToString())) right.Name = dr["Name"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("ZhuJiangRen")) if (!string.IsNullOrEmpty(dr["ZhuJiangRen"].ToString())) right.ZhuJiangRen = dr["ZhuJiangRen"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("JiangZuoShiJijan")) if (!string.IsNullOrEmpty(dr["JiangZuoShiJijan"].ToString())) right.JiangZuoShiJijan = dr["JiangZuoShiJijan"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("JiangZuoDiDian")) if (!string.IsNullOrEmpty(dr["JiangZuoDiDian"].ToString())) right.JiangZuoDiDian = dr["JiangZuoDiDian"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("OrgName")) if (!string.IsNullOrEmpty(dr["OrgName"].ToString())) right.OrgName = dr["OrgName"].ToString();
            if (dr.Table != null && dr.Table.Columns.Contains("YiFaFang")) if (!string.IsNullOrEmpty(dr["YiFaFang"].ToString()))
                {
                    right.YiFaFang = Convert.ToBoolean(dr["YiFaFang"]);
                    right.YiFaFangString = right.YiFaFang == true ? "已发放" : "未发放";
                }
            if (dr.Table != null && dr.Table.Columns.Contains("FaFangFangShi")) if (!string.IsNullOrEmpty(dr["FaFangFangShi"].ToString())) right.FaFangFangShi = dr["FaFangFangShi"].ToString();
            return right;
        }
    }
}
